#include "SWKNXDataStruct.h"

SWKNXDataStruct::SWKNXDataStruct()
{
    m_groupAddress = 0;
    m_knxLen = 0;
    m_dataList.clear();
    m_controlPointList.clear();
}
quint16 SWKNXDataStruct::groupAddress() const
{
    return m_groupAddress;
}
void SWKNXDataStruct::setGroupAddress(const quint16 &address)
{
    m_groupAddress = address;
}

quint16 SWKNXDataStruct::fbAddress() const
{
    return m_fbAddress;
}
  void SWKNXDataStruct::setFBAddress(const quint16 &address)
  {
      m_fbAddress = address;
  }

quint16 SWKNXDataStruct::knxLen() const
{
    return m_knxLen;
}
void SWKNXDataStruct::setKnxLen (const quint16 &len)
{
    m_knxLen = len;
}


QByteArray SWKNXDataStruct:: dataList() const
{
    return m_dataList;
}
void SWKNXDataStruct::setDataList(const QByteArray &dataList)
{
    m_dataList = dataList;
}

quint64 SWKNXDataStruct::delayTime() const
{
    return m_delayTime;
}
void SWKNXDataStruct::setDelayTime(quint64 delayTime)
{
    m_delayTime = delayTime;
}


QList<ControlPointStruct> SWKNXDataStruct::controlPointList() const
{
    return m_controlPointList;
}

void SWKNXDataStruct::setControlPointList(const QList<ControlPointStruct> &controlPointList)
{
    m_controlPointList = controlPointList;
}

bool SWKNXDataStruct::
operator ==(const SWKNXDataStruct &rhs) const
{
    if (m_groupAddress == rhs.groupAddress())// && (m_knxLen == rhs.knxLen()))
    {
        if(m_dataList.size() == rhs.dataList().size())
        {
            for(int i=0;i<m_dataList.size();i++)
            {
                if(m_dataList.at(i) != rhs.dataList().at(i))
                    return false;
            }
            {

            return true;
            }
        }
        else
         return false;
    }
    return false;
}

bool SWKNXDataStruct::operator <(const SWKNXDataStruct &rhs) const
{
    if (m_groupAddress < rhs.groupAddress())
    {
        return true;
    }
    if(m_dataList.size() < rhs.dataList().size())
        return true;

    if(m_dataList.size() == rhs.dataList().size())
    {


        for(int i=0;i<m_dataList.size();i++)
         {
              if(m_dataList.at(i) >= rhs.dataList().at(i))
                   return false;
              else if(m_dataList.at(i) < rhs.dataList().at(i))
              {

                  return true;
              }
          }
        return true;
    }


    return false;
}

